#include "attribprototype.h"


AttribPrototype::AttribPrototype( string _name, string _symbol )
: m_name( _name )
, m_symbol( _symbol )
, m_applyOnVertex( false )
, m_applyOnEdge( false )
, m_applyOnFace( false )
{

}


void 
AttribPrototype::applyOnVertex()
{
  m_applyOnVertex = true;
}

void 
AttribPrototype::applyOnEdge()
{
  m_applyOnEdge = true;
}

void 
AttribPrototype::applyOnFace()
{
  m_applyOnFace = true;
}


void 
AttribPrototype::setProperty( string _name, string _type, int _dir )
{
  m_propertyName.push_back( _name );
  m_propertyType.push_back( _type );
  m_propertySymb.push_back( _dir );
}


string 
AttribPrototype::getName()
{
  return m_name;
}


vector<string> 
AttribPrototype::getPropertyNames()
{
  return m_propertyName;
}


vector<string> 
AttribPrototype::getPropertyTypes()
{
  return m_propertyType;
}

string 
AttribPrototype::getPropertyType( string _prop )
{
  for( int i=0; i<m_propertyName.size(); i++ )
  {
    if( m_propertyName[i] == _prop )
    {
      return m_propertyType[i];
    }
  }
  return "";
}

int 
AttribPrototype::getPropertySymb( string _prop )
{
  for( int i=0; i<m_propertyName.size(); i++ )
  {
    if( m_propertyName[i] == _prop )
    {
      return m_propertySymb[i];
    }
  }
  return 0;
}



vector<int> 
AttribPrototype::getSymbol( int _d, int _s )
{
  vector<int> pts;
  if( m_symbol == "Triangle")
  {
    if( _d ==  1 )
    {
      pts.push_back( -2 );  pts.push_back( +1 );
      pts.push_back( 0 );   pts.push_back( 0 );
      pts.push_back( 0 );   pts.push_back( 0 );
      pts.push_back( -2 );  pts.push_back( -1 );
      pts.push_back( -2 );  pts.push_back( -1 );
      pts.push_back( -2 );  pts.push_back( +1 );
    }
    else if( _d ==  2 )
    {
      pts.push_back( -1 );  pts.push_back( -2 );
      pts.push_back( +1 );  pts.push_back( -2 );
      pts.push_back( +1 );  pts.push_back( -2 );
      pts.push_back( 0 );   pts.push_back( 0 );
      pts.push_back( 0 );   pts.push_back( 0 );
      pts.push_back( -1 );  pts.push_back( -2 );
    }
  }
  else if( m_symbol == "Arrow")
  {
    if( _d ==  1 )
    {
      if( _s ==  0 )
      {
        pts.push_back( +1 );  pts.push_back( -1 );
        pts.push_back( 0 );   pts.push_back( 0 );
        pts.push_back( 0 );   pts.push_back( 0 );
        pts.push_back( +1 );  pts.push_back( +1 );
        pts.push_back( 0 );   pts.push_back( 0 );
        pts.push_back( +2 );  pts.push_back( 0 );
      }
      else if( _s ==  1 )
      {
        pts.push_back( -1 );  pts.push_back( -1 );
        pts.push_back( 0 );   pts.push_back( 0 );
        pts.push_back( 0 );   pts.push_back( 0 );
        pts.push_back( -1 );  pts.push_back( +1 );
        pts.push_back( 0 );   pts.push_back( 0 );
        pts.push_back( -2 );  pts.push_back( 0 );
      }
    }
    else if( _d ==  2 )
    {
      if( _s ==  0 )
      {
        pts.push_back( -1 );  pts.push_back( +1 );
        pts.push_back( 0 );   pts.push_back( 0 );
        pts.push_back( 0 );   pts.push_back( 0 );
        pts.push_back( +1 );  pts.push_back( +1 );
        pts.push_back( 0 );   pts.push_back( 0 );
        pts.push_back( 0 );   pts.push_back( +2 );
      }
      else if( _s ==  1 )
      {
        pts.push_back( -1 );  pts.push_back( -1 );
        pts.push_back( 0 );   pts.push_back( 0 );
        pts.push_back( 0 );   pts.push_back( 0 );
        pts.push_back( +1 );  pts.push_back( -1 );
        pts.push_back( 0 );   pts.push_back( 0 );
        pts.push_back( 0 );   pts.push_back( -2 );
      }
    }
  }
  else if( m_symbol == "M")
  {
    pts.push_back( -1 );  pts.push_back( -1 );
    pts.push_back( -1 );  pts.push_back( +1 );
    pts.push_back( -1 );  pts.push_back( +1 );
    pts.push_back( 0 );   pts.push_back( 0 );
    pts.push_back( 0 );   pts.push_back( 0 );
    pts.push_back( +1 );  pts.push_back( +1 );
    pts.push_back( +1 );  pts.push_back( +1 );
    pts.push_back( +1 );  pts.push_back( -1 );
  }
  return pts;
}
